var fs = require('fs');

var data = '';

// 创建可读流
var readerStream = fs.createReadStream('./stream.txt');
readerStream.setEncoding('UTF8');
// console.log(readerStream);

readerStream.on('data', function (chunk) {
    data += chunk;
});

readerStream.on('end',function(chunk){
    console.log(data);
});

readerStream.on('error',function(err){
    console.log(err);
});
console.log('执行完毕！');